<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- lazy就是将@input改成了@change，改变并且失去焦点才会触发 -->
      <input type="text" v-model.lazy="textValue" />
      <p>{{ textValue }}</p>

      <!-- number修饰符是将string类型尝试转成number类型 -->
      <input type="number" v-model.number="numberValue" />
      <p>{{ numberValue }}</p>
      <p>{{ typeof numberValue }}</p>

      <!-- trim修饰符帮助去掉前后空格 -->
      <input type="text" v-model.trim="trimValue" />
      <p>{{ trimValue }}</p>
      <button @click="fn">btn</button>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          textValue: "",
          numberValue: 9,
          trimValue: "",
        },
        methods: {
          fn() {
            console.log(this.trimValue);
          },
        },
      });
    </script>
  </body>
</html>
